import {
	http
} from "/utils/http.js"

//查询全部旅游项目
export const getListAllAPI = () => {
	return http({
		method: 'GET',
		url: '/api/common/listAll',
	})
}

//提交游客订单信息
export const submitTouristInfoAPI = (data) => {
	return http({
		method: 'POST',
		url: '/api/tourist/insert',
		data: data,
		header: {
			'content-type': 'application/json'
		}
	})
}

//查询所有订单
export const getOrdersById=(identity,id)=>{
	// console.log("identity:"+identity+"id:"+id)
	return http({
		method:'GET',
		url:`/api/${identity}/list/${id}`
		// url:`/api/${identity}/list/2a20474f9822480528f30a6fb388483f`
	})
}
//确认订单
export const confirmTouristInfoAPI = (orderId,state) => {
	console.log("更改订单状态")
	return http({
		method: 'POST',
		url: '/api/tourist/updateToBeSign',
		data:{
			orderId,
			state
		},
		header: {
			"Content-Type": "application/x-www-form-urlencoded;charset=UTF-8",
		}
	})
}
//微信支付
export const wxPayAPI = (orderNo, amount, openid) => {
	return http({
		method: 'POST',
		url: '/api/wxpay/createOrder',
		data: {
			orderNo,
			amount,
			openid
		}
	})
}
// 获取openid
export const getOpenidByCodeAPI = (data) => {
  return http({
    method: 'POST',
    url: '/api/getOpenId',
    data,
    headers: {
      'Content-Type': 'multipart/form-data'
    }
  });
};

// 文件上传
export const uploadFile = (data) => {
  return http({
    method: 'POST',
    url: '/api/upload',
    data,
    headers: {
      'Content-Type': 'multipart/form-data'
    }
  });
};

export const loginByWechat = (data) => {
  return http({
    url: '/api/getOpenId',
    method: 'POST',
    data:data,
	header: {
	      'Content-Type': 'application/json' // 根据后端要求调整
	    }
  });
};